package cn.edu.fudan.segmentstandard;

import cn.edu.fudan.data.*;
import cn.edu.fudan.rule.Classifier;
import cn.edu.fudan.rule.RuleGeneration;
import cn.edu.fudan.rule.RulePruning;
import cn.edu.fudan.rule.WaveletPre;
import cn.edu.fudan.tools.GetConfig;
import cn.edu.fudan.type.*;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 80494 on 2017/4/19.
 */
public class SegmentStandard {
    private static Logger logger = Logger.getLogger(SegmentStandard.class);

    public static void main(String[] args) throws IOException {
        String datasetname = "FaceFour";
        System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
        Config config;
        try {
            config = new GetConfig().getConfig();
            logger.info(config);

            String path = config.getPath();

            String filePath = path + datasetname;
            String trainPath = path + datasetname + "\\" + datasetname + "_TRAIN";
            String testPath = path + datasetname + "\\" + datasetname + "_TEST";
            //String trainPath = path + subject + "\\train.txt";
            //String testPath = path + subject + "\\test.txt";

            ReadData readData = new ReadData();
            ExtractFeature extractFeature = new ExtractFeature();
            HandelFeature handelFeature = new HandelFeature();
            SlideWindow slideWindow = new SlideWindow();
            HandleDistance handleDistance = new HandleDistance();
            WaveletPre waveletPre = new WaveletPre();
            RulePruning rulePruning = new RulePruning();
            RuleGeneration ruleGeneration = new RuleGeneration();
            Classifier classifier = new Classifier();

            List<List<DataItem>> database = new ArrayList<>();
            List<WaveletPerOrder> trainpre = new ArrayList<>();
            List<WaveletPerOrder> testpre = new ArrayList<>();
            List<Rule> ruleset = new ArrayList<>();

            int count = 0;
            double accuracy = 0.0;

            List<List<DataItem>> traindata = new ArrayList<>();
            List<List<DataItem>> testdata = new ArrayList<>();
            Integer trainclass_num = 0;
            Integer testclass_num = 0;
            int class_num = 0;

            try {
                TwoTuple<List<List<DataItem>>, Integer> traintwotuple = readData.readTimeFromUCRFormat(trainPath);
                TwoTuple<List<List<DataItem>>, Integer> testtwotuple = readData.readTimeFromUCRFormat(testPath);
                traindata = traintwotuple.first;
                System.out.println("Initial traindata success.");
                testdata = testtwotuple.first;
                System.out.println("Initial testdata success.");
                trainclass_num = traintwotuple.second;
                System.out.println("Initial train success.");
                testclass_num = testtwotuple.second;
                System.out.println("Initial test success.");
                class_num = Math.max(testclass_num, trainclass_num);
                System.out.println("Initial classnumber success.");
            } catch (Exception e) {
                e.printStackTrace();
                // TODO Auto-generated catch block e.printStackTrace();
            }
            if (traindata.size() > 0 && testdata.size() > 0 && class_num > 0) {
                long begin = System.currentTimeMillis();

            }
        }catch (IOException e1) { // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}